<template>
  <div class="check-form">
    <el-dialog title="题目审核" :visible.sync="dialogFormVisible">
      <el-form ref="form" :model="formBase" :rules="rule">
        <el-form-item prop="chkState">
          <el-radio-group v-model="formBase.chkState">
            <el-radio label="1">通过</el-radio>
            <el-radio label="2">拒绝</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item prop="chkRemarks">
          <el-input type="textarea" rows="3" v-model="formBase.chkRemarks" placeholder="请输入审核意见"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormH">{{$t('table.cancel')}}</el-button>
        <el-button type="primary" @click="submitData">{{$t('table.confirm')}}</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  props: {
    formBase: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      dialogFormVisible: false,
      // 表单验证
      rule: {
        chkState: [{ required: true, message: "请选择", trigger: "blur" }],
        chkRemarks: [
          { required: true, message: "请输入审核意见", trigger: "blur" }
        ]
      }
    };
  },
  methods: {
    // 弹层显示
    dialogFormV() {
      this.dialogFormVisible = true;
    },
    // 弹层隐藏
    dialogFormH() {
      this.dialogFormVisible = false;
    },
    // 表单提交
    submitData() {
      this.$refs.form.validate(async valid => {
        if (valid) {
          this.dialogFormH();
          this.$emit("check", this.formBase);
        } else {
          this.$message.warning("请输入审核意见!");
        }
      });
    }
  }
};
</script>
<style lang="less" scoped>
::v-deep .el-dialog {
  width: 500px;
  .el-dialog__footer {
    text-align: center;
  }
  .el-dialog__body {
    padding: 30px 50px;
  }
}
</style>
